# coding:utf-8
import time


class SetCommonParam:
    """"""
    HTTPS = 'https://'
    HOST = 'cns.api.qcloud.com'
    PATH = '/v2/index.php?'

    param = {}

    def __init__(self):
        self.set_Timestamp(int(time.time()))
        self.set_Nonce("6")

    def _add_param(self, k, v):
        self.param[k] = v

    def add_param(self, k, v):
        self._add_param(k, v)

    def get_param(self):
        return self.param

    def set_Action(self, value):
        self._add_param('Action', value)

    def set_Region(self, value):
        self._add_param('Region', value)

    def set_Timestamp(self, v):
        self._add_param('Timestamp', v)

    def set_Nonce(self, v):
        self._add_param('Nonce', v)

    def set_SecretId(self, v):
        self._add_param('SecretId', v)

    def set_Signature(self, v):
        # 签名字符串
        self._add_param('Signature', v)

    def set_SignatureMethod(self, v='HmacSHA1'):
        self._add_param('SignatureMethod', v)

    def set_Token(self, v):
        self._add_param('Token', v)


class SetDNSRecordParam(SetCommonParam):

    def __init__(self):
        super().__init__()
        self.set_Action('RecordList')

    def set_domain(self, v):
        self._add_param('domain', v)

    def set_offset(self, v):
        self._add_param('offset', v)

    def set_length(self, v):
        self._add_param('length', v)

    def set_subDomain(self, v):
        self._add_param('subDomain', v)

    def set_recordType(self, v):
        self._add_param('recordType', v)

    def set_qProjectId(self, v):
        self._add_param('qProjectId', v)


class Sign:
    """

    """

    def __init__(self):
        pass
